package com.lion.seaman.common.model;

import java.util.concurrent.TimeUnit;

public class TimeValue {
    long value;
    TimeUnit timeUnit;

    public TimeValue() {

    }

    public TimeValue(long value, TimeUnit timeUnit) {
        if (timeUnit == null) {
            throw new NullPointerException("timeUnit must not be null");
        }
        this.value = value;
        this.timeUnit = timeUnit;
    }

    public static TimeValue create(long value, TimeUnit timeUnit) {
        return new TimeValue(value, timeUnit);
    }

    public long toMillis() {
        return timeUnit.toMillis(value);
    }

    public long getValue() {
        return value;
    }

    public void setValue(long value) {
        this.value = value;
    }

    public TimeUnit getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(TimeUnit timeUnit) {
        this.timeUnit = timeUnit;
    }
}
